package com.xjm_cloud_admin.service.impl;

import com.xjm_cloud_admin.domain.XjmRecycle;
import com.xjm_cloud_admin.mapper.XjmRecycleMapper;
import com.xjm_cloud_admin.service.XjmRecycleService;
import com.xjm_cloud_admin.util.R;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;

/**
 * 回收表(XjmRecycle)表服务实现类
 *
 * @author 浪漫写尽歌谱
 * @since 2024-04-23 18:32:32
 */
@Service("xjmRecycleService")
public class XjmRecycleServiceImpl extends ServiceImpl<XjmRecycleMapper, XjmRecycle> implements XjmRecycleService {
    @Resource
    private XjmRecycleMapper xjmRecycleMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param fileId 主键
     * @return 实例对象
     */
    @Override
    public R queryById(Long fileId) {
        return R.success(this.xjmRecycleMapper.queryById(fileId));
    }

    /**
     * 全查询
     *
     * @param xjmRecycle 筛选条件
     * @return 查询结果
     */
    @Override
    public R queryAll(XjmRecycle xjmRecycle) {
        return R.success(this.xjmRecycleMapper.queryAll(xjmRecycle));
    }

    /**
     * 新增数据
     *
     * @param xjmRecycle 实例对象
     * @return 实例对象
     */
    @Override
    public R insert(XjmRecycle xjmRecycle) {
        this.xjmRecycleMapper.insert(xjmRecycle);
        return R.success(xjmRecycle);
    }

    /**
     * 修改数据
     *
     * @param xjmRecycle 实例对象
     * @return 实例对象
     */
    @Override
    public R update(XjmRecycle xjmRecycle) {
        this.xjmRecycleMapper.update(xjmRecycle);
        return R.success(this.queryById(xjmRecycle.getFileId()));
    }

    /**
     * 通过主键删除数据
     *
     * @param fileId 主键
     * @return 是否成功
     */
    @Override
    public R deleteById(Long fileId) {
        boolean del = this.xjmRecycleMapper.deleteById(fileId) > 0;
        return R.success(del);
    }
}

